// 文件上传
jQuery(function() {


	var UploadDownload = function(element, option) {
		var that = this;
		this.$element = $(element);
		this.option = option;
        this.DIALOG_CLASS="upload-dialog";
        this.uploadStatus = 'done';
        this.nameCache = {};

        this.option.btnName = (null == this.option.btnName || '' == this.option.btnName) ? '上传' : this.option.btnName;
        this.option.showUploadButton= (null == this.option.showUploadButton) ? true : this.option.showUploadButton;

		this.getAttachmentsByBoxId = that.option.basePath + '/attachment/getAttachmentsByBoxId.json';
        this.getAttachmentsByBoxMetadata = that.option.basePath + '/attachment/getAttachmentsByBoxMetadata.json';

        this.download = that.option.basePath + '/attachment/download.json';

		this.up = that.option.basePath + '/attachment/serialnumber/up.json';
        this.down = that.option.basePath + '/attachment/serialnumber/down.json';

        this.uploadByBoxId = that.option.basePath + '/attachment/uploadByBoxId.json';
        this.uploadByBIWithValudate = basePath + '/attachment/withvalidate/uploadByBoxId.json';

        this.uploadByBoxMetadata = that.option.basePath + '/attachment/uploadByBoxMetadata.json';
        this.uploadByBMWithValudate = basePath + '/attachment/withvalidate/uploadByBoxMetadata.json';

        this.deleteBoxByMetadata = that.option.basePath + '/attachment/deleteBoxByMetadata.json';
		this.deleteAttachment = that.option.basePath + '/attachment/deleteAttachment.json';
		this.deleteBoxByBoxId = that.option.basePath + '/attachment/deleteBoxByBoxId.json';
		this.preview = that.option.basePath + '/attachment/getPreviewMetadata.json';

		this.uploadByStoreAddress =  that.option.basePath + '/attachment/uploadByStoreAddress.json';

		this.swfPath = that.option.basePath + '/static/ui-frame/webuploader/0.1.5/Uploader.swf';

		this.exaimArgs();

        this.loadTable(this);
    }

	/**
	 * 只接受如下几种参数，形式：|如果有boxId则其他都不用验证，如果没有
	 *  5.	系统id，模块id，文种id，流程实例id；
	 *	6.	系统id，模块id，文种id；
	 *	7.	系统id，模块id；
	 *	8.	系统id。
     *
	 */
        UploadDownload.prototype.exaimArgs = function(){
            this.$table = this.$element
            this.$title= null == (this.option.title ||''==this.option.title)?"上传附件":this.option.title
            this.$isreadonly = this.option.isReadonly

            if(null == this.$isreadonly){
                throw new Error('请指定加载的附件列表是否为只读的.为表格加上[data-is-readonly=true]则是只读表格,false则不是')
            }

            this.$boxid = this.option.boxId
            this.$groupcode = this.option.groupCode
            
            
            this.$validateClass = this.option.validateClass

            if(null == this.$boxid||'' == this.$boxid){

                this.selectPath = this.getAttachmentsByBoxMetadata;
                this.uploadPath = this.uploadByBoxMetadata;
                
                if(this.$validateClass){
                	this.uploadPath = this.uploadByBMWithValudate;
                }
                
            }else{
            	this.selectPath = this.getAttachmentsByBoxId;
                this.uploadPath = this.uploadByBoxId;
                
                if(this.$validateClass){
                	this.uploadPath = this.uploadByBIWithValudate;
                }
            }
            this.deletePath = this.deleteAttachment;
            this.downloadPath = this.download;
            this.moveupPath = this.up;
            this.movedownPath = this.down;
            this.previewPath = this.preview;
            this.previewDeletePath = this.previewDelete;

        }
        UploadDownload.prototype.loadTable = function(that){

            if(that.option.isReadonly){

            	that.loadReadonlyTable();
            }else{
            		that.loadOperateTable();
            }
        }
        UploadDownload.prototype.loadReadonlyTable = function(){
        	var url = this.downloadPath+"?address=";
            var that = this;

            $.ajax({
            type : "get",
            url : that.selectPath,
            cache:false,
            dataType : "json",
            data :{
                areaId:this.$boxid,
                serialNumber:this.$groupcode}
            }).done(function(reslist){
            	var attachSum = reslist.attachmentList.length;

            	that.$table.css('width','100%;').html('<tr><td class="firsttd"  style="word-break:break-all;text-align:left;padding:0px;"></td></tr>');
            	   var aHtmls = '';
               	$.each(reslist.attachmentList,function(index,val){
               		aHtmls = aHtmls + '<img src="'+url+val.attachmentId+'&isinline=true "  width="400" />'
               		aHtmls = aHtmls + '<a href="javascript:void(0);" data-id="'+val.attachmentId+'" class="download-a" title="'+val.fileName+'" style="display:inline-block;padding: 3px;background-color: #FFE7B7;color: #444;margin:2px;">'+val.fileName+'</a>&nbsp;&nbsp;&nbsp;&nbsp;';
                 });
               	
            	

            	that.$table.find('td.firsttd').first().html(aHtmls);
            	
                that.$table.data("attachSum",attachSum);


                that.bingDownloadA(that);


            })
            .fail(function(r){
            	throw new Error('初始化文件列表失败');
            });
        }

     

        UploadDownload.prototype.loadOperateTable = function(){
        	var url = this.downloadPath+"?address=";
            var loadDtd = $.Deferred();

            var that = this;

            $.ajax({
            type : "get",
            url : that.selectPath,
            cache:false,
            dataType : "json",
            data :  {
                areaId:that.$boxid,
                serialNumber:that.$groupcode
            }
            }).done(function(reslist){

            	var attachSum = reslist.attachmentList.length;
            	if(that.option.showUploadButton){
                	that.$table.html('<tr><td class="firsttd col-xs-10" style="word-break:break-all;text-align:left;padding:0px;"></td><td class="col-xs-2"><a href="javascript:;" class="upload-fn-btn" >'+that.option.btnName+'</a></td></tr>');
            	}else{
            		that.$table.html('<tr><td class="firsttd col-xs-12" style="word-break:break-all;text-align:left;padding:0px;"></td></tr>');
            	}
            	var aHtmls = '';
               	$.each(reslist.attachmentList,function(index,val){
               		aHtmls = aHtmls + '<img src="'+url+val.attachmentId+'&isinline=true "  width="400" />'
               		aHtmls = aHtmls + '<a href="javascript:void(0);" data-id="'+val.attachmentId+'" class="download-a" title="'+val.fileName+'" style="display:inline-block;padding: 3px;background-color: #FFE7B7;color: #444;margin:2px;">'+val.fileName+'</a><a href="javascript:void(0);" data-id="'+val.attachmentId+'" class="delete-a"><i class="fa fa fa-trash-o icon-gray"></i><font>删除<font></a>&nbsp;&nbsp;&nbsp;&nbsp;';
                });
               	
            	
            	
            	that.$table.find('td.firsttd').first().html(aHtmls);

                 that.$table.data("attachSum",attachSum);

                 that.$table.find('a.upload-fn-btn').click(function(){
                     that.openUploadDialog()
                  });
                 
                 that.bingDownloadA(that);
                 

                 that.bingDeleteA(that);


                 loadDtd.resolve(attachSum);

            }).fail(function(r){

            	throw new Error('初始化文件列表失败');
                loadDtd.reject();
            });
            return loadDtd;
        }

       
        UploadDownload.prototype.bingDownloadA = function(that){
        	 that.$table.find('a.download-a').click(function(){
                 var _this = $(this);
                 var _id = _this.data('id');
                 var ids = new Array();
                 	ids.push(_id);
                 that.downloadAttach(ids);
             });
        }
        UploadDownload.prototype.bingDeleteA = function(that){
        	that.$table.find('a.delete-a').click(function(){
                var _this = $(this);
                var _id = _this.data('id');
                BootstrapUDialog.confirm('删除后附件不可恢复,确定删除?', function(result){
                    if(result) {
                    	 that.deleteById(_id).done(function(){
                             that.loadTable(that);
                         }).fail(function(){
                             BootstrapUDialog.alert({ title: '提醒', message: '删除失败！', closable: true,  draggable: true });
                         });
                    }
                });

            });
        }
        UploadDownload.prototype.deleteById = function(_id){
            var that = this;
            var dtd = $.Deferred();
            $.ajax({
            type : "post",
            url : that.deletePath,
            dataType : "json",
            data : {
                attachmentId:_id
            }
            }).done(function(res){
                dtd.resolve();
            }).fail(function(res){
                dtd.reject();
            });
            return dtd.promise();
        }
        UploadDownload.prototype.downloadAttach = function(ids){
        	var url = this.downloadPath+"?address="+ids;
        	var downloadIframe = document.getElementById('downLoadIframe');
        	if(downloadIframe){
        		downloadIframe.src = url;
        	}else{
        		downloadIframe = document.createElement('iframe');
        		downloadIframe.id = 'downLoadIframe';
        		downloadIframe.src = url;
        		downloadIframe.style.display = "none";
        		document.body.appendChild(downloadIframe);
        	}
        }

 

        UploadDownload.prototype.uploadByStoreAdress = function(_srcStoreAddress,_destfilename){
        	var that = this;
            var dtd = $.Deferred();
            $.ajax({
                type : "post",
                url : that.uploadByStoreAddress,
                cache:false,
                dataType : "json",
                data :  {srcStoreAddress:_srcStoreAddress,destSystemId:that.$systemid,destfilename:_destfilename,
                        areaId:that.$boxid,
                        serialNumber:that.$groupcode
                		}
                }).done(function(res){
                    dtd.resolve(res);
                }).fail(function(res){
                    dtd.reject();
                });
            return dtd.promise();
        }


        UploadDownload.prototype.openUploadDialog = function(){
        	this.uploaderId = BootstrapUDialog.newGuid();
        	this.filePickerId = BootstrapUDialog.newGuid();
        	this.$validateClass = this.$element.data().validateClass;
        	
        	 if (window.applicationCache) {
                this.$dialog =   $('<div id="'+ this.uploaderId +'"><div id="f'+this.filePickerId+'" class="filePicker" style="float:right;">选择文件</div><div style="clear:both;"></div><div class="fileList"><p class="note">请点击选择文件或拖动文件到这里:单个文件不能大于30M</p></div></div>');
             } else {
                this.$dialog =   $('<div id="'+ this.uploaderId +'"><div id="f'+this.filePickerId+'" class="filePicker" style="float:right;">选择文件</div><div style="clear:both;"></div><div class="fileList"><p class="note">请点击选择文件:单个文件不能大于30M</p></div></div>');
             }
            var that = this;
              BootstrapUDialog.show({
                title: that.$title,
                message: that.$dialog,
                cssClass: that.DIALOG_CLASS,
                closable: false,
                onshown:function(){
                    var $list = that.$dialog.find('.fileList').first();


                    var setting = {
                            pick : '#f'+that.filePickerId,
                            formData:{
                                areaId:that.$boxid,
                                serialNumber:that.$groupcode,
                                validateClass:that.$validateClass
                            },
                            swf : that.swfPath,

                            server : that.uploadPath,
                            fileSingleSizeLimit: 30*1024*1024 //30M
                        };
                    var _accept = that.$element.data('accept');
                    if(null != _accept){
                    	var accs = _accept.split('_');
                    	if(null != accs){
                    		var map = {};
                    		for(var i = 0;i< accs.length; i++){
                    			var kv = accs[i].split(':');
                    			if(null != kv && kv.length == 2){
                    				map[kv[0]] = kv[1];
                    			}
                    		}
                    		setting = $.extend({accept:map},setting);
                    	}
                    	
                    }
                    
                    

                    if ( !WebUploader.Uploader.support() ) {
                    	BootstrapUDialog.alert( '文件上传不支持您的浏览器！如果你使用的是IE浏览器，请尝试升级 flash 播放器');
                        throw new Error( 'WebUploader does not support the browser you are using.' );
                    }
                    if (window.applicationCache) {
                    	setting = $.extend({ dnd: '#' + that.uploaderId + ' .fileList',paste: document.body,disableGlobalDnd: true},setting)
                    }
                    that.uploadInstance = WebUploader.create(setting);
                    that.uploadInstance.on( 'beforeFileQueued', function( file ) {
                    	if(file.name.length > 50){
                            this.trigger( 'error', 'FILE_NAME_SIZE_OVER', 50, file );
                            return false;
                    	}else{
                    		return true;
                    	}
                    });

                    that.uploadInstance.on('fileQueued', function(file) {
                    	var $txt = $('#' + that.uploaderId + ' .fileList p');
                    	if('block' == $txt.css('display')){
                    		$txt.hide();
                    	}
                        var $div = $('<div id="' + file.id + '" class="item"><h4 class="info">' + file.name + '&nbsp;<i class="fa fa-times deleteI" data-id=""></i></h4><p class="state">等待上传...</p>' + '</div>');
                        $list.append($div);


                        var $deleteI = $div.find('.deleteI').first();
                        $deleteI.click(function(){
                            var $ele = $(this);
                            var id = $ele.parent().parent().attr("id");
                            that.uploadInstance.removeFile( id, true );
                            var fileId = $ele.data('id');
                            if(null !=  fileId && '' !=  fileId){
                                that.deleteById(fileId).done(function(){
                                    $ele.parent().parent().remove();
                                }).fail(function(){
                                    BootstrapUDialog.alert({ title: '提醒', message: '删除失败！', closable: true,  draggable: true });
                                });
                            }else{
                                $ele.parent().parent().remove();
                            }
                        });
                    });
                    that.uploadInstance.on('fileQueued', function (file) {
                        that.uploadInstance.upload();
                    });


                    that.uploadInstance.on('error',function(type,max,file){
                    	if('F_EXCEED_SIZE' == type){
                    		BootstrapUDialog.alert({ title: '提醒', message: file.name+'大于30M,请选择小于30M的文件！', closable: true,  draggable: true });
                    	}else if('FILE_NAME_SIZE_OVER' == type){
                    		BootstrapUDialog.alert({ title: '提醒', message: file.name+'上传的文件名最长'+max+'个字符！', closable: true,  draggable: true });
                    	}
                    });


                    that.uploadInstance
                            .on(
                                    'uploadProgress',
                                    function(file, percentage) {
                                        var $li = $('#' + file.id), $percent = $li.find('.progress .progress-bar');

                                        if (!$percent.length) {
                                            $percent = $('<div class="progress progress-striped active"><div class="progress-bar" role="progressbar" style="width: 0%"></div></div>').appendTo($li).find('.progress-bar');
                                        }

                                        $li.find('p.state').text('上传中');

                                        $percent.css('width', percentage * 100 + '%');
                                    });

                    that.uploadInstance.on('uploadSuccess', function(file,res) {
                    	if(that.$validateClass){
                    		if(res.result){
                                var $li = $('#' + file.id), $deleteI = $li.find('.deleteI'), $progress = $li.find('.progress');
                                $deleteI.data('id',res.data[0].id);
                                $('#' + file.id).find('p.state').text('上传成功');
                                $progress.remove();
                        	}else{
                        		this.trigger( 'uploadError', file, res.message );
                        	}
                    	}else{

                            var $li = $('#' + file.id), $deleteI = $li.find('.deleteI'), $progress = $li.find('.progress');
                            $deleteI.data('id',res.attachmentList[0].id);
                            $('#' + file.id).find('p.state').text('上传成功');
                            $progress.remove();
                    	}
                    	
                    	
                    	
                    });

                    that.uploadInstance.on('uploadError', function(file ,message) {
                        var $li = $('#' + file.id), $progress = $li.find('.progress');
                        if(null != message && '' != message){
                            $('#' + file.id).find('p.state').text(message + ',上传失败');
                        }else{
                            $('#' + file.id).find('p.state').text('上传失败');
                        }
                        $progress.remove();
                    });


                    that.uploadInstance.on('all', function(type) {
                        switch( type ) {
                            case 'uploadFinished':
                                that.uploadStatus = 'done';
                                break;

                            case 'startUpload':
                                that.uploadStatus = 'uploading';
                                break;

                            case 'stopUpload':
                                that.uploadStatus = 'paused';
                                break;

                        }
                    });

                },
                buttons: [ {
                    label: '确定',
                    action: function(dialogRef){
                        if(null != that.uploadStatus && 'done' == that.uploadStatus){
                    		that.loadOperateTable().done(function(attachSum){
                                that.$table.trigger("attachLoaded",attachSum);
                    		});
                            if(null != that.uploadInstance){
                                that.uploadInstance.destroy();
                            }
                            dialogRef.close();
                        }else{
                            BootstrapUDialog.alert({ title: '提醒', message: "请等待上传完毕", closable: true,  draggable: true });
                        }
                    }},{
                    label: '取消',
                    action: function(dialogRef){
                        if(null != that.uploadInstance){
                        	that.$dialog.find('.deleteI').each(function(){
                        		$(this).click();
                        	});
                            that.uploadInstance.destroy();
                        }
                        dialogRef.close();
                    }
                }]
            });
	   }




	//当前工程basepath
	UploadDownload.basePath = basePath;

	UploadDownload.VERSION  = '1.0.0';





	function Plugin(option) {
		return this.each(function() {
			var $this = $(this);
			var data = $this.data('upload.uploaddownloaddata');
			if (!data) {
				var eOption = $this.data()

				var options = $.extend({}, {'basePath':UploadDownload.basePath},eOption, typeof option == 'object' && option);
				$this.data('upload.uploaddownloaddata', (data = new UploadDownload(this,options)));
			}
		})
	}

	var old = $.fn.UploadDownload;

	$.fn.UploadDownload             = Plugin;
	$.fn.UploadDownload.Constructor = UploadDownload;

	//UploadDownload NO CONFLICT
	//=================

	$.fn.UploadDownload.noConflict = function () {
	$.fn.UploadDownload = old;
	return this;
	};
	$(document).ready(function() {
		Plugin.call($('.upload-download-element'));
		$.fn.uploaddownload = function() {
			var uploaddownInstance = $(this).data('upload.uploaddownloaddata');
			if(uploaddownInstance){
				uploaddownInstance.openUploadDialog()
			}else{
				throw new Error('请指定正确的目标table');
			}
		}
	});


});

/*! Sea.js 2.2.1 | seajs.org/LICENSE.md */
!function(a,b){function c(a){return function(b){return{}.toString.call(b)=="[object "+a+"]"}}function d(){return A++}function e(a){return a.match(D)[0]}function f(a){for(a=a.replace(E,"/");a.match(F);)a=a.replace(F,"/");return a=a.replace(G,"$1/")}function g(a){var b=a.length-1,c=a.charAt(b);return"#"===c?a.substring(0,b):".js"===a.substring(b-2)||a.indexOf("?")>0||".css"===a.substring(b-3)||"/"===c?a:a+".js"}function h(a){var b=v.alias;return b&&x(b[a])?b[a]:a}function i(a){var b=v.paths,c;return b&&(c=a.match(H))&&x(b[c[1]])&&(a=b[c[1]]+c[2]),a}function j(a){var b=v.vars;return b&&a.indexOf("{")>-1&&(a=a.replace(I,function(a,c){return x(b[c])?b[c]:a})),a}function k(a){var b=v.map,c=a;if(b)for(var d=0,e=b.length;e>d;d++){var f=b[d];if(c=z(f)?f(a)||a:a.replace(f[0],f[1]),c!==a)break}return c}function l(a,b){var c,d=a.charAt(0);if(J.test(a))c=a;else if("."===d)c=f((b?e(b):v.cwd)+a);else if("/"===d){var g=v.cwd.match(K);c=g?g[0]+a.substring(1):a}else c=v.base+a;return 0===c.indexOf("//")&&(c=location.protocol+c),c}function m(a,b){if(!a)return"";a=h(a),a=i(a),a=j(a),a=g(a);var c=l(a,b);return c=k(c)}function n(a){return a.hasAttribute?a.src:a.getAttribute("src",4)}function o(a,b,c){var d=S.test(a),e=L.createElement(d?"link":"script");if(c){var f=z(c)?c(a):c;f&&(e.charset=f)}p(e,b,d,a),d?(e.rel="stylesheet",e.href=a):(e.async=!0,e.src=a),T=e,R?Q.insertBefore(e,R):Q.appendChild(e),T=null}function p(a,c,d,e){function f(){a.onload=a.onerror=a.onreadystatechange=null,d||v.debug||Q.removeChild(a),a=null,c()}var g="onload"in a;return!d||!V&&g?(g?(a.onload=f,a.onerror=function(){C("error",{uri:e,node:a}),f()}):a.onreadystatechange=function(){/loaded|complete/.test(a.readyState)&&f()},b):(setTimeout(function(){q(a,c)},1),b)}function q(a,b){var c=a.sheet,d;if(V)c&&(d=!0);else if(c)try{c.cssRules&&(d=!0)}catch(e){"NS_ERROR_DOM_SECURITY_ERR"===e.name&&(d=!0)}setTimeout(function(){d?b():q(a,b)},20)}function r(){if(T)return T;if(U&&"interactive"===U.readyState)return U;for(var a=Q.getElementsByTagName("script"),b=a.length-1;b>=0;b--){var c=a[b];if("interactive"===c.readyState)return U=c}}function s(a){var b=[];return a.replace(X,"").replace(W,function(a,c,d){d&&b.push(d)}),b}function t(a,b){this.uri=a,this.dependencies=b||[],this.exports=null,this.status=0,this._waitings={},this._remain=0}if(!a.seajs){var u=a.seajs={version:"2.2.1"},v=u.data={},w=c("Object"),x=c("String"),y=Array.isArray||c("Array"),z=c("Function"),A=0,B=v.events={};u.on=function(a,b){var c=B[a]||(B[a]=[]);return c.push(b),u},u.off=function(a,b){if(!a&&!b)return B=v.events={},u;var c=B[a];if(c)if(b)for(var d=c.length-1;d>=0;d--)c[d]===b&&c.splice(d,1);else delete B[a];return u};var C=u.emit=function(a){var b=B[a],c;if(b){b=b.slice();for(var d=Array.prototype.slice.call(arguments,1);c=b.shift();)c.apply(null,d)}return u},D=/[^?#]*\//,E=/\/\.\//g,F=/\/[^/]+\/\.\.\//,G=/([^:/])\/\//g,H=/^([^/:]+)(\/.+)$/,I=/{([^{]+)}/g,J=/^\/\/.|:\//,K=/^.*?\/\/.*?\//,L=document,M=e(L.URL),N=L.scripts,O=L.getElementById("seajsnode")||N[N.length-1],P=e(n(O)||M);u.resolve=m;var Q=L.head||L.getElementsByTagName("head")[0]||L.documentElement,R=Q.getElementsByTagName("base")[0],S=/\.css(?:\?|$)/i,T,U,V=+navigator.userAgent.replace(/.*(?:AppleWebKit|AndroidWebKit)\/(\d+).*/,"$1")<536;u.request=o;var W=/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|\/\*[\S\s]*?\*\/|\/(?:\\\/|[^\/\r\n])+\/(?=[^\/])|\/\/.*|\.\s*require|(?:^|[^$])\brequire\s*\(\s*(["'])(.+?)\1\s*\)/g,X=/\\\\/g,Y=u.cache={},Z,$={},_={},ab={},bb=t.STATUS={FETCHING:1,SAVED:2,LOADING:3,LOADED:4,EXECUTING:5,EXECUTED:6};t.prototype.resolve=function(){for(var a=this,b=a.dependencies,c=[],d=0,e=b.length;e>d;d++)c[d]=t.resolve(b[d],a.uri);return c},t.prototype.load=function(){var a=this;if(!(a.status>=bb.LOADING)){a.status=bb.LOADING;var c=a.resolve();C("load",c,a);for(var d=a._remain=c.length,e,f=0;d>f;f++)e=t.get(c[f]),e.status<bb.LOADED?e._waitings[a.uri]=(e._waitings[a.uri]||0)+1:a._remain--;if(0===a._remain)return a.onload(),b;var g={};for(f=0;d>f;f++)e=Y[c[f]],e.status<bb.FETCHING?e.fetch(g):e.status===bb.SAVED&&e.load();for(var h in g)g.hasOwnProperty(h)&&g[h]()}},t.prototype.onload=function(){var a=this;a.status=bb.LOADED,a.callback&&a.callback();var b=a._waitings,c,d;for(c in b)b.hasOwnProperty(c)&&(d=Y[c],d._remain-=b[c],0===d._remain&&d.onload());delete a._waitings,delete a._remain},t.prototype.fetch=function(a){function c(){u.request(g.requestUri,g.onRequest,g.charset)}function d(){delete $[h],_[h]=!0,Z&&(t.save(f,Z),Z=null);var a,b=ab[h];for(delete ab[h];a=b.shift();)a.load()}var e=this,f=e.uri;e.status=bb.FETCHING;var g={uri:f};C("fetch",g);var h=g.requestUri||f;return!h||_[h]?(e.load(),b):$[h]?(ab[h].push(e),b):($[h]=!0,ab[h]=[e],C("request",g={uri:f,requestUri:h,onRequest:d,charset:v.charset}),g.requested||(a?a[g.requestUri]=c:c()),b)},t.prototype.exec=function(){function a(b){return t.get(a.resolve(b)).exec()}var c=this;if(c.status>=bb.EXECUTING)return c.exports;c.status=bb.EXECUTING;var e=c.uri;a.resolve=function(a){return t.resolve(a,e)},a.async=function(b,c){return t.use(b,c,e+"_async_"+d()),a};var f=c.factory,g=z(f)?f(a,c.exports={},c):f;return g===b&&(g=c.exports),delete c.factory,c.exports=g,c.status=bb.EXECUTED,C("exec",c),g},t.resolve=function(a,b){var c={id:a,refUri:b};return C("resolve",c),c.uri||u.resolve(c.id,b)},t.define=function(a,c,d){var e=arguments.length;1===e?(d=a,a=b):2===e&&(d=c,y(a)?(c=a,a=b):c=b),!y(c)&&z(d)&&(c=s(""+d));var f={id:a,uri:t.resolve(a),deps:c,factory:d};if(!f.uri&&L.attachEvent){var g=r();g&&(f.uri=g.src)}C("define",f),f.uri?t.save(f.uri,f):Z=f},t.save=function(a,b){var c=t.get(a);c.status<bb.SAVED&&(c.id=b.id||a,c.dependencies=b.deps||[],c.factory=b.factory,c.status=bb.SAVED)},t.get=function(a,b){return Y[a]||(Y[a]=new t(a,b))},t.use=function(b,c,d){var e=t.get(d,y(b)?b:[b]);e.callback=function(){for(var b=[],d=e.resolve(),f=0,g=d.length;g>f;f++)b[f]=Y[d[f]].exec();c&&c.apply(a,b),delete e.callback},e.load()},t.preload=function(a){var b=v.preload,c=b.length;c?t.use(b,function(){b.splice(0,c),t.preload(a)},v.cwd+"_preload_"+d()):a()},u.use=function(a,b){return t.preload(function(){t.use(a,b,v.cwd+"_use_"+d())}),u},t.define.cmd={},a.define=t.define,u.Module=t,v.fetchedList=_,v.cid=d,u.require=function(a){var b=t.get(t.resolve(a));return b.status<bb.EXECUTING&&(b.onload(),b.exec()),b.exports};var cb=/^(.+?\/)(\?\?)?(seajs\/)+/;v.base=(P.match(cb)||["",P])[1],v.dir=P,v.cwd=M,v.charset="utf-8",v.preload=function(){var a=[],b=location.search.replace(/(seajs-\w+)(&|$)/g,"$1=1$2");return b+=" "+L.cookie,b.replace(/(seajs-\w+)=1/g,function(b,c){a.push(c)}),a}(),u.config=function(a){for(var b in a){var c=a[b],d=v[b];if(d&&w(d))for(var e in c)d[e]=c[e];else y(d)?c=d.concat(c):"base"===b&&("/"!==c.slice(-1)&&(c+="/"),c=l(c)),v[b]=c}return C("config",a),u}}}(this);
// Set configuration
seajs.config({
  base: basePath + "/static/ui-frame/"
});

/*! WebUploader 0.1.5 */

try{
	WebUploader;
}catch(e){
	seajs.use("webuploader/0.1.5/webuploader.min");
}
/*modal BootstrapUDialog*/
try{
	BootstrapUDialog;
}catch(e){
	seajs.use("bootstrap-m-dialog3/js/bootstrap-m-dialog.min");
}